import qs from 'qs'
import request from '@/utils/request'

// 签名
import _bale from '@/utils/package'
// 获取不同的接口地址
import { uploadApi } from '@/api/index'

// 查询交易订单
export function getOrderInfo(params) {
  return request({
    url: '/order/getOrderInfo',
    method: 'post',
    data: qs.stringify(_bale('getOrderInfo', params))
  })
}

// 查询交易订单详情
export function getOrderDetails(params) {
  return request({
    url: '/order/getOrderDetails',
    method: 'post',
    data: qs.stringify(_bale('getOrderDetails', params))
  })
}

// 关闭交易订单
export function closeOrder(params) {
  return request({
    url: '/order/closeOrder',
    method: 'post',
    data: qs.stringify(_bale('closeOrder', params))
  })
}

// 删除已关闭订单
export function deleteCloseOrder(params) {
  return request({
    url: '/order/deleteCloseOrder',
    method: 'post',
    data: qs.stringify(_bale('deleteCloseOrder', params))
  })
}

// 确认收货
export function confirmOrder(params) {
  return request({
    url: '/order/confirmOrder',
    method: 'post',
    data: qs.stringify(_bale('confirmOrder', params))
  })
}

// 确认售后商品信息
export function getReturnGoods(params) {
  return request({
    url: '/return/getReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('getReturnGoods', params))
  })
}

// 导入商品库存，接受两个参数file，和params
export function upload(file, params) {
  return request({
    timeout: 180000,
    url: uploadApi + '/upload/img' + _bale('img', params, true),
    method: 'post',
    data: file // file不做签名
  })
}

// 确认售后商品信息
export function applyReturnGoods(params) {
  return request({
    url: '/return/applyReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('applyReturnGoods', params))
  })
}

// 确认售后商品信息
export function getReturnDetails(params) {
  return request({
    url: '/return/getReturnDetails',
    method: 'post',
    data: qs.stringify(_bale('getReturnDetails', params))
  })
}

// 确认售后商品信息
export function revokeReturnGoods(params) {
  return request({
    url: '/return/revokeReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('revokeReturnGoods', params))
  })
}

// 修改已申请售后
export function updateReturnGoods(params) {
  return request({
    url: '/return/updateReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('updateReturnGoods', params))
  })
}
